<?
/*
 *   Pmail easy way to send emails
 *   Copyright (C) 2009  Felipe Theodoro Gonçalves (www.ftgoncalves.com)
 *
 *   This program is free software: you can redistribute it and/or modify
 *	 it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
?>
<div id="page">
	<h2><?= __d('pmail', 'Groups') ?></h2>
	<table>
		<caption class="left"><?= __d('pmail', 'List of groups') ?></caption>
		<thead>
			<tr>
				<th scope="col"><?= __d('pmail', 'Identifier') ?></th>
				<th scope="col"><?= __d('pmail', 'Created') ?></th>
				<th scope="col"><?= __d('pmail', 'Option') ?></th>
			</tr>
		</thead>
		<tbody>
			<?php
				$count = 0;
				if(empty($groups)){
					echo '<tr><td colspan="3">' . __d('pmail', 'No group configured. Create a group now', true) . $html->link(__d('pmail', 'click here', true), array('plugin' => 'pmail', 'controller' => 'groups', 'action' => 'add_group')) . '!</td></tr>';
				}else{
					foreach($groups as $aux){
						foreach($aux as $group){
							echo '<tr id="' . $count++ . '">';
								echo '<td>' . $group['name'] . '</td>';
								echo '<td>' . str_replace('-','/',substr($group['created'],0,10)) . '</td>';
								echo '<td>';
									echo $html->link($html->image('/pmail/img/iconeEditar.gif', array('alt' => 'Editar', 'border' => 0)), array('plugin' => 'pmail', 'controller' => 'groups', 'action' => 'edit_group', 'id' => $group['id']), array(), false, false);
							  		echo $html->link($html->image('/pmail/img/iconeExcluir.gif', array('alt' => 'Excluir', 'border' => 0)), array('plugin' => 'pmail', 'controller' => 'groups', 'action' => 'delete_group', 'id' => $group['id']), array(), __d('pmail', __d('pmail', 'Are you sure you want to delete this group. All group members will also be deleted', true), true), false);
								echo '</td>';
							echo '</tr>';
						}
					}
				}
			?>
		</tbody>
	</table>
</div>
<div id="sidebar">
	<h4><?= __d('pmail', 'Coments') ?></h4>
	<p><?= __d('pmail', 'Set up the groups. The groups are given for reference in the e-mails') ?>.</p>
	<?= $this->requestAction('/pmail/groups/menu') ?>
	<?= $this->renderElement('recommended/links') ?>
</div>
<div class="clear"></div>
<script type="text/javascript">
	$().ready(function(){
		$('table tbody tr:odd').addClass('impar');
	});
</script>